package br.com.jvet.entidade;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import br.com.jvet.constante.GeneroAnimal;

@Entity
@Table(name = "tbanimal")
@SequenceGenerator(name = "animal_seq", sequenceName = "animal_seq", initialValue = 1, allocationSize = 1)
public class Animal implements Serializable {

	private static final long serialVersionUID = -7831600499267683175L;
	@Column(name="idanimal")
	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "animal_seq")
	private int codigo;
	@Column(name = "nome_animal",nullable=false,length=150)
	private String nome;
	@Column
	@Temporal(TemporalType.DATE)
	private Date dataNascimento;
	@Column(name="dt_cadastro")
	@Temporal(TemporalType.DATE)
	private Date dataCadastro;
	@ManyToOne
	@JoinColumn(name="idcliente")
	private Cliente cliente;
	@OneToOne
	private Raca raca;
	@OneToOne
	private TipoAnimal tipoAnimal;
	@Column(name="cor_animal")
	private String cor;
	@Column(name="sexo_animal")
	@Enumerated(EnumType.ORDINAL)
	private GeneroAnimal generoAnimal;
	

	public Animal() {
		super();

	}

	public int getCodigo() {
		return codigo;
	}

	public void setCodigo(int codigo) {
		this.codigo = codigo;
	}

	public String getNome() {
		return nome;
	}

	public void setNome(String nome) {
		this.nome = nome;
	}

	public Date getDataNascimento() {
		return dataNascimento;
	}

	public void setDataNascimento(Date dataNascimento) {
		this.dataNascimento = dataNascimento;
	}

	public Cliente getCliente() {
		return cliente;
	}

	public void setCliente(Cliente cliente) {
		this.cliente = cliente;
	}

	@Override
	public String toString() {
		return "Animal [codigo=" + codigo + ", nome=" + nome
				+ ", dataNascimento=" + dataNascimento + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + codigo;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Animal other = (Animal) obj;
		if (codigo != other.codigo)
			return false;
		return true;
	}

}
